/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.psi.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author chopin
 */
public class ConnDB {
    public static final String url = "jdbc:mysql://127.0.0.1/psidb";  
    public static final String name = "com.mysql.jdbc.Driver";  
    public static final String user = "xiaogang";  
    public static final String password = "xiaogang";  
  
    public Connection conn = null;  
    public PreparedStatement pst = null;  
  
    public  void getConn() {  
        try {  
            Class.forName(name);//指定连接类型  
            conn = DriverManager.getConnection(url, user, password);//获取连接  
            System.out.println("sucessfuf");
        } catch (ClassNotFoundException | SQLException e) {  
            System.out.print(url);
        }  
    }  
  
    public void close() {  
        try {  
            this.conn.close();  
            this.pst.close();  
        } catch (SQLException e) {  
        }  
    }  
    public static void main(String[] args) {
        ConnDB db = new ConnDB();
        db.getConn();
    }
}
